package com.hmy.gateway.config;

import com.hmy.gateway.constant.SecurityConstant;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * Web配置
 *
 * @author xiongwei
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {

    /**
     * 跨域设置
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .exposedHeaders(SecurityConstant.NEW_ACCESS_TOKEN, SecurityConstant.NEW_REFRESH_TOKEN)
                .allowedOrigins(CorsConfiguration.ALL)
                .allowedMethods(CorsConfiguration.ALL)
                .allowedHeaders(CorsConfiguration.ALL);
    }

}
